package lei;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.util.Random;
public class Column {
    //图片
    public BufferedImage image;
    //位置
    public int x,y;
    //宽高
    public int width,height;
    //柱子之间的缝隙
    public int gap;
    //柱子之间的距离
    public int distance;
    //随机数工具
    Random random=new Random();
    /**
     * 初始化第N个柱子
     */
    public Column(int n) throws Exception{
        image=ImageIO.read(getClass().getResource("/resources/column.png"));
        width=image.getWidth();
        height=image.getHeight();
        gap=144;
        distance=245;
        x=550+(n-1)*distance;
        y=random.nextInt(218)+123;
    }
    //向左移动一步
    public void step() {
        x--;
        if(x==-width/2) {
            y=distance*2-width/2;
            y=random.nextInt(218)+132;
            x=550;
        }
    }
}

